/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2013/03/17
* File: ParameterManager.cpp
* Blog: http://www.cnblogs.com/zengqh/
**/

#include "Parameter.h"
#include "ParameterManager.h"

namespace HY
{

uint32 ParameterManager::getNumOfParams() const
{
	return param_map_.size();
}

Parameter* ParameterManager::createParam(uint32 type, const std::string& name)
{
	if (type >= Parameter::UnknownDataType)
	{
		return 0;
	}

	return new Parameter(this, type, name);
}

Parameter* ParameterManager::getParam(const std::string& name) const
{
	std::map<std::string, Parameter*>::const_iterator iter;
	iter = param_map_.find(name);
	if (iter != param_map_.end())
	{
		return iter->second;
	}

	return 0;
}

void ParameterManager::removeAllParams()
{
	param_map_.clear();
}

ParameterManager::ParameterManager()
{

}

ParameterManager::~ParameterManager()
{
	removeAllParams();
}

bool ParameterManager::isParam(const std::string& name) const
{
	std::map<std::string, Parameter*>::const_iterator iter;
	iter = param_map_.find(name);
	if (iter != param_map_.end())
	{
		return true;
	}

	return false;
}

}